package com.example.administrator.newsmvp.news.presenter;


import com.example.administrator.newsmvp.beans.NewsBean;
import com.example.administrator.newsmvp.news.model.NewsModel;
import com.example.administrator.newsmvp.news.model.NewsModelImpl;
import com.example.administrator.newsmvp.news.model.OnResultListener;
import com.example.administrator.newsmvp.news.view.NewsView;
import com.example.administrator.newsmvp.news.widget.NewsListFragment;

import java.util.List;


public class NewsPresenter {

    private NewsView mNewsView;
    private NewsModel mNewsModel;

    public NewsPresenter(NewsListFragment newsView) {
        this.mNewsView = newsView;
        this.mNewsModel = new NewsModelImpl();
    }

    public void loadData(String type) {
        mNewsModel.loadData(type, new OnResultListener() {
            @Override
            public void onFailure() {
                mNewsView.failure();
            }

            @Override
            public void onSuccess(List<NewsBean> datas) {
                mNewsView.loadData(datas);
            }
        });
    }

}
